package myapp.DTO;

import myapp.EnumAndConstans.Constants;

import org.json.JSONException;
import org.json.JSONObject;

public class UserDTO
{
    public int id;

    public String email;

    private String pwd;

    public double latitude;

    public double longtitude;

    public String name;

    public int avatarId;
    
    public int available;

//    public UserDTO(USER user)
//    {
//        Id = user.Id;
//        Email = user.Email.Trim();
//        Pwd = user.Password.Trim();
//        Latitude = Convert.ToDouble(user.Latitude);
//        Longtitude = Convert.ToDouble(user.Longtitude);
//        Name = user.Name;
//        AvatarId = user.AvartarId == null ? -1 : Convert.ToInt32(user.AvartarId);
//    }

    public UserDTO()
    {
    }
    
    public UserDTO(int id, String email, String pwd, double latitude, double longtitude, String name, int avatarId, int available){
    	this.id = id;
    	this.email = email;
    	this.pwd = pwd;
    	this.latitude = latitude;
    	this.longtitude = longtitude;
    	this.name = name;
    	this.avatarId = avatarId;
    	this.available = available;
    }
    
    public UserDTO(String email, double latitude, double longtitude){
    	this.id = Constants.NOT_AVAILABLE;
    	this.email = email;
    	this.pwd = "";
    	this.name = "";
    	this.latitude = latitude;
    	this.longtitude = longtitude;
    	this.available = Constants.STATUS_AVAILABLE;
    	this.avatarId = Constants.NOT_AVAILABLE;
    }
    
    public UserDTO(String email, int available){
    	this.id = Constants.NOT_AVAILABLE;
    	this.email = email;
    	this.pwd = "";
    	this.name = "";
    	this.latitude = Constants.STATUS_AVAILABLE;
    	this.longtitude = Constants.STATUS_AVAILABLE;
    	this.available = available;
    	this.avatarId = Constants.NOT_AVAILABLE;
    }
    
    public JSONObject toJson() throws JSONException{
    	JSONObject json = new JSONObject();
    	json.put("Id", this.id);
		json.put("Email", this.email);
		json.put("Pwd", this.pwd);
		json.put("Latitude", this.latitude);
		json.put("Longtitude", this.longtitude);
		json.put("Name", this.name);
		json.put("AvatarId", this.avatarId);
		json.put("Available", this.available);
    	return json;
    }
}
